
package flc.ast.dialog;

import android.content.Context;
import android.view.View;

import androidx.annotation.NonNull;

import com.lxj.xpopup.core.AttachPopupView;

import flc.ast.R;

public class EditDialog extends AttachPopupView implements View.OnClickListener {


    public EditDialog(@NonNull Context context) {
        super(context);
    }

    @Override
    protected int getImplLayoutId() {
        return R.layout.dialog_edit;
    }

    @Override
    protected void onCreate() {
        super.onCreate();
        initView();
    }

    protected void initView() {
        findViewById(R.id.tvDelete).setOnClickListener(this);
        findViewById(R.id.tvRename).setOnClickListener(this);
        findViewById(R.id.tvMove).setOnClickListener(this);
        findViewById(R.id.tvCopy).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        int id = v.getId();
        if (id == R.id.tvDelete) {
            dismiss();
            if (listener != null) {
                listener.clickDelete();
            }
        }else if (id == R.id.tvRename) {
            dismiss();
            if (listener != null) {
                listener.clickRename();
            }
        }else if (id == R.id.tvMove) {
            dismiss();
            if (listener != null) {
                listener.clickMove();
            }
        }else if (id == R.id.tvCopy) {
            dismiss();
            if (listener != null) {
                listener.clickCopy();
            }
        }
    }

    private Ilistener listener;

    public void setListener(Ilistener listener) {
        this.listener = listener;
    }

    public interface Ilistener {
        void clickDelete();

        void clickRename();

        void clickMove();

        void clickCopy();
    }

}
